import { requestClient } from '#/api/request'

/**
 * 获取分类列表
 */
export async function getTypeList(params: {
  page: any
  size: any
  name?: any
}) {
  return requestClient.get('/getGoodsTypeList', {
    params,
  })
}

/**
 * 添加分类
 */
export async function addType(data: { name: string; storeId: number; order: number }) {
  return requestClient.post('/addGoodsType', data)
}

/**
 * 修改分类
 */
export async function updateType(data: {
  name: string
  storeId: number
  order: number
  id: number
}) {
  return requestClient.put('/editGoodsType/' + data.id, data)
}

/**
 * 删除分类
 */
export async function deleteType(id: any) {
  return requestClient.delete('/deleteGoodsType/' + id)
}

/**
 * 获取商品列表
 */
export async function getGoodsList(params: {
  page: any
  pageSize: any
  name?: any
}) {
  return requestClient.get('/goods', {
    params,
  })
}

/**
 * 添加商品
 */
export async function addGoods(data: { 
  name: string
  price: number
  num: number
  tid: number
  img: string
  details: string 
}) {
  return requestClient.post('/goods', data)
}

/**
 * 修改商品
 */
export async function updateGoods(data: { 
  name: string
  price: number
  num: number
  tid: number
  img: string
  details: string
  id: number 
}) {
  return requestClient.put('/goods/' + data.id, data)
}

/**
 * 删除商品
 */
export async function deleteGoods(id: any) {
  return requestClient.delete('/goods/' + id)
}
